package www.lagou.app;

import jdk.jfr.StackTrace;
import org.junit.Test;
import www.lagou.Dao.AccountDao;

import java.math.BigDecimal;
import java.sql.SQLException;

public class TestAccountDao {
    //创建账户的持久层对象
    AccountDao ad = new AccountDao();
    @Test
    /**
     * 实现卡号：1122334455向55443332211转账5000元的操作
     */
    public void transfer() throws SQLException {
        //检查转出账户的余额是否充足
        int tmp = ad.getBalanceByCard("1122334455").compareTo((Double) 5000.00);
        if(tmp == -1){
            //如果余额不足，给出提示
            System.out.println("余额不足" + ad.getBalanceByCard("1122334455"));
            //正常结束程序
            System.exit(0);
        }
        //调用ad对象的自定义方法进行转账操作，返回标志flag
        boolean flag = ad.bankTransfer("1122334455","55443332211", (double) 5000);
        if(flag){
            System.out.println("Tom向Lucy转账5000元");//转账成功
        }else{
            System.out.println("转账失败");
        }
    }

}
